package _08作业.t4;

import java.io.*;
import java.net.Socket;

public class UploadClient {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1",9999);
        FileInputStream fis = new FileInputStream("day12\\客户端文件夹\\bg.jpg");
        OutputStream sos = socket.getOutputStream();
        byte[] bytes = new byte[1024];
        int read;
        while ((read=fis.read(bytes))!=-1){
            sos.write(bytes,0,read);
        }
        socket.shutdownOutput();

        InputStream socketInputStream = socket.getInputStream();
        while ((read=socketInputStream.read(bytes))!=-1){{
            System.out.println(new String(bytes,0,read));
        }}
        socketInputStream.close();
        sos.close();
        fis.close();
        socket.close();
    }
}
